package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import io.swagger.models.auth.In;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zzy
 * @date 2022/7/15 15:13
 */

@RestController
@RequestMapping("/api/v1/channel")
public class WmchannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult list(){
        return wmChannelService.channelList();
    }

    @PostMapping("/save")
    public ResponseResult inster(@RequestBody WmChannel wmChannel){
        return wmChannelService.inster(wmChannel);
    }

    @PostMapping("/list")
    public ResponseResult find(@RequestBody ChannelDto dto){
        return wmChannelService.find(dto);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        return wmChannelService.update(wmChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable ("id") Integer id){
        return wmChannelService.delete(id);
    }

}
